package com.gistone.commis.controller;

import com.gistone.commis.util.CaptchaUtil;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * Created by wangfan on 2017/4/29.
 */
@Controller
public class HomeController {

//    @RequestMapping(value={"/",""})
//    public String home() throws IOException {
//       return "static/index.html";
////        return "index";
//    }

    @RequestMapping(value="")
    public String index() throws IOException {
        return "login.html";
    }
    @RequestMapping(value="loginPage")
    public String loginPage() throws IOException {
        return "login.html";
    }



    @RequestMapping(value="/user/userhome")
    @ResponseBody
    public String uuserhome() throws IOException {
        System.out.println(111);
        return "index.html";
    }

    @RequestMapping("/user/yzmimg")
    @ResponseBody
    public void execute(HttpServletRequest request , HttpServletResponse response) throws Exception {
        try {
            // 设置跨域
            request.setCharacterEncoding("utf-8");
            response.setContentType("text/html;charset=utf-8");
            System.out.println("HomeController  获取验证码成功！");
            CaptchaUtil.outputCaptcha(request, response);
        } catch (Exception e) {
            System.out.println("HomeController 获取验证码异常！");
        }

    }




}
